home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / misc / math / MathFX_src.lha / fxstyl.c < prev    next >
C/C++ Source or Header  |  1995-12-20  |  1KB  |  51 lines

  1. /* Set up a new line style of "nels" elements, with mark and space */
  2. /* lengths given by arrays "mk" and "sp". */
  3.  
  4. #include "mathfx.h"
  5. #include "declare.h"
  6.  
  7. void fxstyl(nels,mk,sp)
  8. int nels,mk[],sp[];
  9. {
  10.     int i;
  11.  
  12.     if ((nels < 0) || (nels > 10)) {
  13.       fatal("Broken lines cannot have <0 or >10 elements");
  14.     }
  15.  
  16.     nms = nels;
  17.     for (i=0; i<nels; i++) {
  18.         mark[i] = mk[i];
  19.         space[i] = sp[i];
  20.         if ((mk[i] < 0) || (sp[i] < 0))
  21.             fatal("Mark and space lengths must be > 0 in FXSTYL");
  22.     }
  23.  
  24.     curel = 0;
  25.     pendn = 1;
  26.     timecnt = 0;
  27.     alarm = mark[curel];
  28. }
  29.  
  30. /* Updates line style variables, called whenever alarm goes off */
  31.  
  32. void fxupd()
  33. {
  34.     while ( timecnt >= alarm ) {
  35.         if (pendn != 0) {
  36.             pendn = 0;
  37.             timecnt = timecnt - alarm;
  38.             alarm = space[curel];
  39.         }
  40.         else {
  41.             pendn = 1;
  42.             timecnt = timecnt - alarm;
  43.             curel = curel + 1;
  44.             if (curel >= nms) curel = 0;
  45.             alarm = mark[curel];
  46.         }
  47.     }
  48. }
  49.  
  50.  
  51.